package com.sqfw.project.wp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sqfw.framework.aspectj.lang.annotation.Log;
import com.sqfw.framework.aspectj.lang.enums.BusinessType;
import com.sqfw.project.wp.domain.WpHurryLog;
import com.sqfw.project.wp.service.IWpHurryLogService;
import com.sqfw.framework.web.controller.BaseController;
import com.sqfw.framework.web.domain.AjaxResult;
import com.sqfw.common.utils.poi.ExcelUtil;
import com.sqfw.framework.web.page.TableDataInfo;

/**
 * 催单日志Controller
 * 
 * @author lx
 * @date 2023-06-28
 */
@RestController
@RequestMapping("/wp/wpHurryLog")
public class WpHurryLogController extends BaseController
{
    @Autowired
    private IWpHurryLogService wpHurryLogService;

    /**
     * 查询催单日志列表
     */
    @PreAuthorize("@ss.hasPermi('wp:wpHurryLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(WpHurryLog wpHurryLog)
    {
        startPage();
        List<WpHurryLog> list = wpHurryLogService.selectWpHurryLogList(wpHurryLog);
        return getDataTable(list);
    }

    /**
     * 导出催单日志列表
     */
    @PreAuthorize("@ss.hasPermi('wp:wpHurryLog:export')")
    @Log(title = "催单日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WpHurryLog wpHurryLog)
    {
        List<WpHurryLog> list = wpHurryLogService.selectWpHurryLogList(wpHurryLog);
        ExcelUtil<WpHurryLog> util = new ExcelUtil<WpHurryLog>(WpHurryLog.class);
        util.exportExcel(response, list, "催单日志数据");
    }

    /**
     * 获取催单日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('wp:wpHurryLog:query')")
    @GetMapping(value = "/{scid}")
    public AjaxResult getInfo(@PathVariable("scid") Long scid)
    {
        return success(wpHurryLogService.selectWpHurryLogByScid(scid));
    }

    /**
     * 新增催单日志
     */
    @PreAuthorize("@ss.hasPermi('wp:wpHurryLog:add')")
    @Log(title = "催单日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WpHurryLog wpHurryLog)
    {
        return toAjax(wpHurryLogService.insertWpHurryLog(wpHurryLog));
    }

    /**
     * 修改催单日志
     */
    @PreAuthorize("@ss.hasPermi('wp:wpHurryLog:edit')")
    @Log(title = "催单日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WpHurryLog wpHurryLog)
    {
        return toAjax(wpHurryLogService.updateWpHurryLog(wpHurryLog));
    }

    /**
     * 删除催单日志
     */
    @PreAuthorize("@ss.hasPermi('wp:wpHurryLog:remove')")
    @Log(title = "催单日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scids}")
    public AjaxResult remove(@PathVariable Long[] scids)
    {
        return toAjax(wpHurryLogService.deleteWpHurryLogByScids(scids));
    }

    /**
     * 根据工单编号查询催单记录列表
     * @param wpHurryLog
     * @return
     */
    @PreAuthorize("@ss.hasPermi('wpHurryLog:getHurryLogList')")
    @GetMapping("/getHurryLogList")
    public AjaxResult getHurryLogList(WpHurryLog wpHurryLog)
    {

        List<WpHurryLog> list = wpHurryLogService.selectWpHurryLogList(wpHurryLog);
        return AjaxResult.success(list);
    }
}
